import { commonGet } from "@/api/commonapi.js"
export default {
	data() {
		return {
			fileList:[],
			$baseUrl:"",
			file:"",
		}
	},
	onLoad() {
		this.$baseUrl = this.baseUrl
		// if(this.$store.state.userIn){
		// 	this.file = JSON.parse(this.$store.state.userIn).logo
		// }
	},
	methods: {
		uploadFile(){
			let _this = this
			uni.chooseFile({
				count:1, //默认9
				type:"all",
				sourceType: ['album','camera' ], //从相册选择
				success: (res) => {
					res.tempFilePaths.forEach((item)=>{
						uni.uploadFile({
							url: _this.$baseUrl+'/ajax/appfile.ashx', //服务器地址
							// fileType: "image", //ZFB必填,不然报错
							filePath: item, //这个就是我们上面拍照返回或者先中照片返回的数组
							name: 'file',
							formData: {
								'ak': _this.$store.state.token								
							},
							success: (uploadFileRes) => {
								console.log('------>',uploadFileRes);
								_this.file = JSON.parse(JSON.parse(uploadFileRes.data).Data.filelist)[0].lj;
							},
							fail:(err)=>{
								console.log(err)
							}
						});
					})
					if (_this.fileList.length != 0) {
						_this.fileList = _this.fileList.concat(res.tempFilePaths)
					} else {
						_this.fileList = res.tempFilePaths
					}
				}
			});
		}
	}
}
